home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
etc
/
RCS
/
sleep.c,v
< prev
next >
Wrap
Text File
|
1990-09-05
|
5KB
|
225 lines
head 1.4;
branch ;
access ;
symbols ;
locks ; strict;
comment @ * @;
1.4
date 90.09.05.18.56.41; author rab; state Exp;
branches ;
next 1.3;
1.3
date 88.12.31.12.26.19; author ouster; state Exp;
branches ;
next 1.2;
1.2
date 88.06.21.17.25.15; author ouster; state Exp;
branches ;
next 1.1;
1.1
date 88.06.19.14.32.02; author ouster; state Exp;
branches ;
next ;
desc
@@
1.4
log
@Replaced old sleep with bsd sleep.
@
text
@/*
* sleep.c --
*
* Source for "sleep" library procedure.
*
* Copyright 1986, 1989 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef lint
static char rcsid[] = "$Header: /sprite/src/lib/c/etc/RCS/sleep.c,v 1.3 88/12/31 12:26:19 ouster Exp Locker: rab $ SPRITE (Berkeley)";
#endif not lint
#include <sys/time.h>
#include <signal.h>
#define setvec(vec, a) \
vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
static int ringring;
static void sleepx();
/*
*----------------------------------------------------------------------
*
* sleep --
*
* Delay process for a given number of seconds.
*
* Results:
* Always returns 0.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
sleep(n)
unsigned n;
{
long omask;
struct itimerval itv, oitv;
register struct itimerval *itp = &itv;
struct sigvec vec, ovec;
if (n == 0)
return;
timerclear(&itp->it_interval);
timerclear(&itp->it_value);
if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
return;
itp->it_value.tv_sec = n;
if (timerisset(&oitv.it_value)) {
if (timercmp(&oitv.it_value, &itp->it_value, >))
oitv.it_value.tv_sec -= itp->it_value.tv_sec;
else {
itp->it_value = oitv.it_value;
/*
* This is a hack, but we must have time to
* return from the setitimer after the alarm
* or else it'll be restarted. And, anyway,
* sleep never did anything more than this before.
*/
oitv.it_value.tv_sec = 1;
oitv.it_value.tv_usec = 0;
}
}
setvec(vec, sleepx);
(void) sigvec(SIGALRM, &vec, &ovec);
omask = sigblock(sigmask(SIGALRM));
ringring = 0;
(void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
while (!ringring)
sigpause(omask &~ sigmask(SIGALRM));
(void) sigvec(SIGALRM, &ovec, (struct sigvec *)0);
(void) sigsetmask(omask);
(void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0);
}
static void
sleepx()
{
ringring = 1;
}
#ifdef WRONG
int
sleep(seconds)
int seconds;
{
struct timeval tv;
tv.tv_sec = seconds;
tv.tv_usec = 0;
(void) select(0, (int *) 0, (int *) 0, (int *) 0, &tv);
return 0;
}
#endif
@
1.3
log
@Simplify so as not to need compatibility routines or Sprite kernel calls.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: sleep.c,v 1.2 88/06/21 17:25:15 ouster Exp $ SPRITE (Berkeley)";
d21 8
d45 46
d92 4
d107 2
@
1.2
log
@Various changes to make code compile under new library.
@
text
@d2 1
a2 1
* kill.c --
d4 1
a4 1
* Procedure to map from Unix sleep system call to Sprite Sync_WaitTime.
d6 8
a13 2
* Copyright 1986 Regents of the University of California
* All rights reserved.
d17 1
a17 1
static char rcsid[] = "$Header: sleep.c,v 1.1 88/06/19 14:32:02 ouster Exp $ SPRITE (Berkeley)";
d20 1
a20 7
#include <sprite.h>
#include <spriteTime.h>
#include <sync.h>
#include "compatInt.h"
#include <errno.h>
d27 1
a27 2
* Procedure to map from Unix sleep library call to Sprite
* Sync_WaitTime.
d30 1
a30 1
* UNIX_SUCCESS is returned.
d42 1
a42 1
Time timeToWait;
d44 4
a47 4
timeToWait.seconds = seconds;
timeToWait.microseconds = 0;
(void) Sync_WaitTime(timeToWait);
return(UNIX_SUCCESS);
@
1.1
log
@Initial revision
@
text
@d11 1
a11 1
static char rcsid[] = "$Header: sigsetmask.c,v 1.1 86/04/17 15:21:06 douglis Exp $ SPRITE (Berkeley)";
d14 3
a16 3
#include "sprite.h"
#include "/sprite/lib/include/time.h"
#include "sync.h"
@